#include "StdAfx.h"
#include "Iocp.h"

using namespace Next::Protocols;

CIocp::CIocp(void)
{
}


CIocp::~CIocp(void)
{
}

bool CIocp::Init()
{
	SYSTEM_INFO	SystemInfo;


	GetSystemInfo(&SystemInfo);

	unsigned int processorCount = SystemInfo.dwNumberOfProcessors * 2 + 1;

	if( processorCount > MAX_WORKER_THREADS )
		processorCount = MAX_WORKER_THREADS;

	this->uThreadCount = processorCount;

	for( unsigned int i = 0; i < this->uThreadCount; i++ ) 
	{
		this->vWorkerThread[i] = (unsigned int)INVALID_HANDLE_VALUE;
	}

	this->hIOCP = INVALID_HANDLE_VALUE;
	this->uPort = DEF_GAMESERVERPORT;
	this->upListenSock = INVALID_SOCKET;

	WSADATA	WsaData;

	if( WSAStartup(MAKEWORD(2,2), &WsaData) )
	{
		return false;
	}

	return true;
}


void CIocp::Clear()
{
	WSACleanup();
}


